<%@ page contentType="text/html;charset=UTF-8" language="java"%>

<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="com.engine.taskmask.persistence.PMF"%>
<%@ page import="com.engine.taskmask.persistence.iTask"%>
<%@ page import="java.util.List"%>
<%@ page import="com.engine.taskmask.persistence.Statistics"%>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Task Mask, Application Web Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link href="bootstrap/css/bootstrap-datetimepicker.min.css"
	rel="stylesheet">

<style type="text/css">

/* Sticky footer styles
      -------------------------------------------------- */
html,body {
	height: 100%;
	/* The html and body elements cannot have any padding or margin. */
}

/* Wrapper for page content to push down footer */
#wrap {
	min-height: 100%;
	height: auto !important;
	height: 100%;
	/* Negative indent footer by it's height */
	margin: 0 auto -60px;
}

/* Set the fixed height of the footer here */
#push,#footer {
	height: 60px;
}

#footer {
	background-color: #f5f5f5;
}

/* Lastly, apply responsive CSS fixes as necessary */
@media ( max-width : 767px) {
	#footer {
		margin-left: -20px;
		margin-right: -20px;
		padding-left: 20px;
		padding-right: 20px;
	}
}

/* Custom page CSS
      -------------------------------------------------- */
/* Not required for template or sticky footer method. */
.container {
	width: auto;
	max-width: 680px;
}

.container .credit {
	margin: 20px 0;
}
</style>

<!-- Le styles -->
<link
	href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css"
	rel="stylesheet">
<link rel="stylesheet" type="text/css" media="screen"
	href="/bootstrap/css/bootstrap-datetimepicker.min.css">


<style>
body {
	padding-top: 60px;
	/* 60px to make the container go all the way to the bottom of the topbar */
}
</style>

<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="../assets/js/html5shiv.js"></script>
    <![endif]-->


</head>

<body>

	<div class="navbar ">
		<div class="navbar-inner">
			<div class="container">
				<button type="button" class="btn btn-navbar" data-toggle="collapse"
					data-target=".nav-collapse">
					<span class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="brand" href="#">Task Mask</a>
				<div class="nav-collapse collapse">
					<ul class="nav">
						<li class="active"><a href="index.html">Home</a></li>
						<li><a href="about.html">About</a></li>
						<li><a href="contact.html">Contact</a></li>
					</ul>
					<ul class="nav pull-right">
						<li class="dropdown"><a href="#" class="dropdown-toggle"
							data-toggle="dropdown">Welcome, <%
							PersistenceManager pm = PMF.get().getPersistenceManager();
							UserService userService = UserServiceFactory.getUserService();
							User user = userService.getCurrentUser();
							if (user != null) {
						%> <%=user.getNickname()%> <%
 	} else {
 %> <%=" Guest"%> <%
 	}
 %> <b class="caret"></b></a>
							<ul class="dropdown-menu">

								<li><a href=""><i class="icon-cog"></i> Preferences</a></li>
								<li><a href="/contact.html"><i class="icon-envelope"></i>
										Contact Support</a></li>
								<li class="divider"></li>

								<li><a
									href="<%=userService.createLoginURL(request.getRequestURI())%>"><i
										class="icon-user"></i> Login</a></li>
								<li><a
									href="<%=userService.createLogoutURL(request.getRequestURI())%>"><i
										class="icon-off"></i> Logout</a></li>
							</ul></li>
					</ul>

				</div>
				<!--/.nav-collapse -->
			</div>
		</div>
	</div>

	<div class="container">

		<%
			if (request.getParameter("id") == null)
				response.sendRedirect("/index.jsp");

			String id_param = request.getParameter("id");
			//entitynin numarasini al
			long id = Long.parseLong(id_param.substring(
					id_param.lastIndexOf('(') + 1, id_param.lastIndexOf(')')));

			// o numaralı (id) sahip task getir.
			iTask task = (iTask) pm.getObjectById(iTask.class, id);
			pm.close();
		%>

		<form name="personal" class="form-horizontal"
			action="/UpdateTaskServlet" method="post"
			enctype='multipart/form-data'>

			<fieldset>

				<!-- Form Name -->
				<legend>Edit Task</legend>

				<!-- Text input-->
				<div class="control-group">
					<label class="control-label">Title:</label>
					<div class="controls">
						<input id="taskTitle" name="taskTitle" type="text"
							class="input-xlarge" value="<%=task.getTaskTitle()%>">

					</div>
				</div>

				<!-- Text input-->
				<div class="control-group">
					<label class="control-label">Location:</label>
					<div class="controls">
						<input id="taskLocation" name="taskLocation" type="text"
							class="input-xlarge" value="<%=task.getTaskLocation()%>">

					</div>
				</div>

				<!-- Date Time Input -->

				<div class="control-group">
					<label class="control-label">Date: </label>
					<div id="datetimepicker" class="input-append date">
						<input type="text" value="<%=task.getDate_s()%>"></input> <span
							class="add-on"> <i data-time-icon="icon-time"
							data-date-icon="icon-calendar"></i>
						</span>
					</div>
				</div>

				<!-- Select Basic -->

				<div class="control-group">
					<label class="control-label">Category:</label>
					<div class="controls">
						<select id="taskCategory" name="taskCategory" class="input-xlarge">
							<%
								String select = "";
								for (int i = 0; i < Statistics.categories.length; i++) {
									if (task.getTaskCategory().equals(Statistics.categories[i]))
										select = select + "<option SELECTED>"
												+ Statistics.categories[i] + "</option>";
									else
										select = select + "<option>" + Statistics.categories[i]
												+ "</option>";
								}
								out.print(select);
							%>
						</select>
					</div>
				</div>

				<!-- Textarea -->
				<div class="control-group">
					<label class="control-label">Notes:</label>
					<div class="controls">
						<textarea id="taskNotes" name="taskNotes"><%=task.getTaskNotes()%></textarea>
					</div>
				</div>

				<div class="control-group">
					<label class="control-label">Check:</label>
					<div class="controls">
						<label class="checkbox"> <input type="checkbox"
							name="taskFlagged"
							value="<%if (task.isTaskFlagged())
				out.print("checked");%> ">
						</label>
					</div>
				</div>

				<!-- Button (Double) -->
				<div class="control-group">
					<label class="control-label"></label>
					<div class="controls">
						<input type="submit" value="Save changes" class="btn btn-info">
					</div>
				</div>
			</fieldset>
		</form>
	</div>
	<!-- /container -->

	<div id="footer">
		<div class="container">
			<p class="muted credit">
				All rights reserved <a href="http://ahmetoz.com.tr">Ahmet ÖZ</a> and
				<a href="#"> Cansu Aras</a> // 2013 - Ege University.
			</p>
		</div>
	</div>

	<script
		src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
	<script
		src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>

	<script src="/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
	<script type="text/javascript">
      $('#datetimepicker').datetimepicker({
        format: 'dd/MM/yyyy',
        pickTime: false
      });
    </script>

</body>
</html>



